package com.lekang.le.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lekang.le.mapper.FamilyMemberMapper;
import com.lekang.le.domain.FamilyMember;
import com.lekang.le.domain.vo.CustomerInfoVO;
import com.lekang.le.service.IFamilyMemberService;

/**
 * 客户信息Service业务层处理
 * 
 * @author xuan
 * @date 2025-10-20
 */
@Service
public class FamilyMemberServiceImpl implements IFamilyMemberService 
{
    @Autowired
    private FamilyMemberMapper familyMemberMapper;

    /**
     * 查询客户信息
     * 
     * @param id 客户信息主键
     * @return 客户信息
     */
    @Override
    public FamilyMember selectFamilyMemberById(Long id)
    {
        return familyMemberMapper.selectFamilyMemberById(id);
    }

    /**
     * 查询客户信息列表
     * 
     * @param familyMember 客户信息
     * @return 客户信息
     */
    @Override
    public List<FamilyMember> selectFamilyMemberList(FamilyMember familyMember)
    {
        return familyMemberMapper.selectFamilyMemberList(familyMember);
    }

    /**
     * 新增客户信息
     * 
     * @param familyMember 客户信息
     * @return 结果
     */
    @Override
    public int insertFamilyMember(FamilyMember familyMember)
    {
        return familyMemberMapper.insertFamilyMember(familyMember);
    }

    /**
     * 修改客户信息
     * 
     * @param familyMember 客户信息
     * @return 结果
     */
    @Override
    public int updateFamilyMember(FamilyMember familyMember)
    {
        return familyMemberMapper.updateFamilyMember(familyMember);
    }

    /**
     * 批量删除客户信息
     * 
     * @param ids 需要删除的客户信息主键
     * @return 结果
     */
    @Override
    public int deleteFamilyMemberByIds(Long[] ids)
    {
        return familyMemberMapper.deleteFamilyMemberByIds(ids);
    }

    /**
     * 删除客户信息信息
     * 
     * @param id 客户信息主键
     * @return 结果
     */
    @Override
    public int deleteFamilyMemberById(Long id)
    {
        return familyMemberMapper.deleteFamilyMemberById(id);
    }

    @Override
    public List<FamilyMember> selectAll(FamilyMember familyMember) {
        List<FamilyMember> familyMembers = familyMemberMapper.selectAll(familyMember);
        System.out.println(familyMembers.get(0));
        for (FamilyMember fm : familyMembers) {
            System.out.println("elderlySzh: " + fm.getElderlySzh());
            if (fm.getElderlySzh() != null) {
                System.out.println("老人姓名: " + fm.getElderlySzh().getName());
            }
        }
        return familyMembers;
    }

    /**
     * 查询客户信息列表（基于微信用户）
     * 
     * @param nickname 客户昵称（用于模糊查询）
     * @param phone 客户手机号（用于模糊查询）
     * @return 客户信息列表
     */
    @Override
    public List<CustomerInfoVO> selectCustomerInfoList(String nickname, String phone) {
        return familyMemberMapper.selectCustomerInfoList(nickname, phone);
    }
}
